package com.graden.background.controller.sysuserlog;


import com.graden.background.controller.sysuserlog.vo.UserLogVO;
import com.graden.background.common.conf.aop.operation.OperationAnnotation;
import com.graden.background.common.enums.OperationEnum;
import com.graden.background.common.utils.apiresult.AbstractApiResult;
import com.graden.background.service.sysuserlog.ISysUserLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 操作日志菜单前端控制器
 * </p>
 *
 * @author zjf
 * @since 2019-03-21
 */
@RestController
@RequestMapping("/user/log")
@Api(tags = {"操作日志"})
public class SysUserLogController {

	@Resource
	ISysUserLogService iSysUserLogService;

	@PostMapping("/page/{pageNo}/{pageSize}")
	@ApiOperation(value = "获取操作日志")
	@OperationAnnotation(operation = OperationEnum.SYSTEM_OPERATION_SEE)
	public AbstractApiResult getPage(@PathVariable int pageNo, @PathVariable int pageSize, @RequestBody UserLogVO userLogVO) {
		return AbstractApiResult.success(iSysUserLogService.getAllByPage(pageNo, pageSize, userLogVO));
	}

	@GetMapping("/get/models")
	@ApiOperation(value = "获取操作模板下拉框")
	public AbstractApiResult getModels() {
		return AbstractApiResult.success(iSysUserLogService.getOperationMenu());
	}

	@GetMapping("/get/operations/{modelId}")
	@ApiOperation(value = "根据操作模板ID获取操作日志")
	public AbstractApiResult getOperations(@PathVariable Integer modelId) {
		return AbstractApiResult.success(iSysUserLogService.getOperationFunction(modelId));
	}

}
